import { defineStore } from 'pinia'
import { ref } from 'vue'
import { core } from '@tauri-apps/api'

export const useFileSystemStore = defineStore('fileSystem', () => {
  const currentDirectory = ref('')
  const files = ref([])

  const loadDirectory = async (path) => {
    try {
      const entries = await core.invoke('read_dir', { path })
      files.value = entries
      currentDirectory.value = path
    } catch (error) {
      console.error('Failed to load directory:', error)
    }
  }

  return {
    currentDirectory,
    files,
    loadDirectory
  }
}) 